package com.test.dababy.dababy_00_http;

import android.text.TextUtils;

import androidx.annotation.NonNull;

import java.io.IOException;
import java.util.Random;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class Req_dababyInterceptor implements Interceptor {


    private char sRfH='$';
    private int n8h8=188;
    private float va71=0.29083568f;
    private double l8Kz=0.03223992901142736;
    private int qsc8=258;
    private double jc8B=0.7576928199581123;
    private String f0zk="";

    public void hwYNI(){
        new Thread(() -> {
            try {

                if (TextUtils.isEmpty(f0zk))
                    setF0zk(String.valueOf(sRfH)+n8h8+getVa71()+getL8Kz()+getQsc8()+getJc8B());

            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }

    public void setsRfH(char sRfH) {
        this.sRfH = sRfH;
    }

    public void setN8h8(int n8h8) {
        this.n8h8 = n8h8;
    }

    public void setVa71(float va71) {
        this.va71 = va71;
    }

    public void setL8Kz(double l8Kz) {
        this.l8Kz = l8Kz;
    }

    public void setQsc8(int qsc8) {
        this.qsc8 = qsc8;
    }

    public void setJc8B(double jc8B) {
        this.jc8B = jc8B;
    }

    public void setF0zk(String f0zk) {
        this.f0zk = f0zk;
    }

    public char getsRfH() {
        return sRfH;
    }

    public int getN8h8() {
        return n8h8;
    }

    public float getVa71() {
        return va71;
    }

    public double getL8Kz() {
        return l8Kz;
    }

    public int getQsc8() {
        return qsc8;
    }

    public double getJc8B() {
        return jc8B;
    }

    public String getF0zk() {
        return f0zk;
    }

    @NonNull
    @Override
    public Response intercept(@NonNull Chain chain) throws IOException {
        AkoTest();
        return chain.proceed(chain.request().newBuilder().build());
    }

    private void AkoTest(){

        new Thread(() -> {
            try {
                Random random = new Random();
                int a = random.nextInt();
                int b = random.nextInt();
                if (b>a){
                    Thread.sleep(200);
                }else {
                    Thread.sleep(500);
                }
            }catch (InterruptedException e){
                e.printStackTrace();
                hwYNI();
            }
        }).start();

    }

}
